package steg.img;

import java.awt.image.BufferedImage;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

import javax.imageio.ImageIO;

public class DeStegImg
{
	public static void main(String[] args) throws IOException
	{
		String path="c:/tmp/test_.bmp";
	   // BufferedImage image = ImageIO.read(new File("c:/tmp/steg1372421970184.bmp"));
	    BufferedImage image = ImageIO.read(new File(path));
		    
		    int row = image.getHeight();
		    int col = image.getWidth();
		    StringBuffer sb = new StringBuffer();
		    for(int r=0;r<row;r++)
		    {
		    	for(int c=0;c<col;c++){
		    		int val = image.getRGB(c,row-r-1)+16777216;
		    		int c1 = val / (1 << 16);
		    		int c2 = (val - (c1 << 16)) / (1 << 8);
		    		int c3 = (val - (c1 << 16) - (c2 << 8));
		    		sb.append((char)c1);
		    		sb.append((char)c2);
		    		sb.append((char)c3);
		    		System.out.println("["+r+","+c+"]\t"+c1+" "+c2+" "+ c3 +"\t" + (char)c1+" "+(char)c2+" "+(char)c3+ "\t" +val);

		    	}
		    	System.out.println(r);
		    }
		    Writer output = new BufferedWriter(new FileWriter(path+".txt"));
		    try {
		      output.write( sb.toString() );
		    }
		    finally {
		      output.close();
		    }
		    
		  
	}
	
}
